var webpack = require("webpack");
var path = require('path');
var ROOT_PATH = path.resolve(__dirname);
var ASSETS_PATH = path.resolve(ROOT_PATH, 'assets');
var PUBLIC_PATH = path.resolve(ROOT_PATH, 'public');

module.exports = {
    entry: ['webpack/hot/dev-server', "./main"],
    output: {
        path: ROOT_PATH,
        filename: "[name].bundle.js",
        publicPath: "/dist/"
    },
    resolve: {
        extensions: ['', '.js', '.ts']
    },
    devtool: 'source-map',
    module: {
        preLoaders: [
            {
                test: /third-party\.scss$/, // target scss
                loader: 'mixin-loader',
            },
        ],
        loaders: [
            {
                test: /\.ts$/,
                loaders: [
                    'awesome-typescript-loader',
                    'angular2-template-loader',
                    'angular2-router-loader'
                ],
                exclude: /node_modules/
            },
            {
                test: /\.html$/,
                loaders: ['html-loader'],
                exclude: /node_modules/
            },
            {
                test: /\.css$/,
                loaders: ["css-to-string-loader", "css"],
                exclude: /node_modules/
            },
            {
                test: /\.(png|jpg)$/,
                loader: 'url-loader?limit=8192'
            } // inline base64 URLs for <=8k images, direct URLs for the rest
            , {
                test: /\.scss$/,
                loaders: ["css-to-string-loader", "raw", "sass"],
                exclude: /node_modules/
            }
        ]
    },
    sassLoader: {
        // `includePaths` is optional
        includePaths: [path.resolve(__dirname, './node_modules/compass-mixins/lib')],
    },
    // plugins: [
    //     new webpack.optimize.CommonsChunkPlugin(/* chunkName= */"vendor", /* filename= */"./public/dist/vendor.bundle.js")
    // ],
    devServer: {
        hot: true,
        inline: true,
        proxy: {
            '**/*.do': {
                "target": "http://localhost:8008",
                changeOrigin: true,
                ws: true,
                secure: false
            }
        },
        contentBase: "./",
        // publicPath: ASSETS_PATH,
        port: 9090,
        watchOptions: {
            aggregateTimeout: 300,
            poll: 1000
        },
        historyApiFallback: true
    }
};